package com.jinlejia.erp.ui.common;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jinlejia.erp.R;
import com.wang.avi.AVLoadingIndicatorView;

/**
 */
public class ProgressDialog extends AlertDialog {
    private String tip;
    private Context mContext;
    public ProgressDialog(Context context) {
        super(context);
    }
    public ProgressDialog(Context context, String tips) {
        super(context);
        this.mContext = context;
        this.tip = tips;
    }
    private boolean canCancel = true;
    public ProgressDialog(Context context, String tips,boolean canCancel){
        super(context);
        this.mContext = context;
        this.tip = tips;
        this.canCancel = canCancel;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setCanceledOnTouchOutside(false);
        Window window = this.getWindow();
        // *** 主要就是在这里实现这种效果的.
        // 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容
        window.setContentView(R.layout.layout_dialog_progress);
        window.setGravity(Gravity.CENTER);
        window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        window.setBackgroundDrawable(new ColorDrawable());
        setCanceledOnTouchOutside(canCancel);
//        AVLoadingIndicatorView circleProgressBar = (AVLoadingIndicatorView) findViewById(R.id.id_progress);
        TextView tips = (TextView) findViewById(R.id.id_progress_tips);
        tips.setText(tip);
    }
}
